using JRO;
using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using System.IO;
public class TaobaoqiangUtil
{
	public OleDbCommand oleDbCommand_0;
	public OleDbCommand oleDbCommand_1;
	public OleDbCommand oleDbCommand_2;
	private OleDbConnection oleDbConnection_0;
	private string string_0;
	public TaobaoqiangUtil()
	{
		this.string_0 = Directory.GetCurrentDirectory();
		this.oleDbCommand_2 = null;
		this.method_0();
	}
	public TaobaoqiangUtil(string string_1)
	{
		this.string_0 = Directory.GetCurrentDirectory();
		this.oleDbCommand_2 = null;
		this.method_1(string_1);
	}
	public void method_0()
	{
		this.method_1(this.string_0 + "\\config\\淘清仓淘抢购.mdb");
	}
	public void method_1(string string_1)
	{
		if (this.oleDbConnection_0 == null)
		{
			string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + string_1 + ";Jet OLEDB:Database Password=taoqq<#>678";
			this.oleDbConnection_0 = new OleDbConnection(connectionString);
			this.oleDbConnection_0.Open();
		}
	}
	public ArrayList method_10(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			ArrayList arrayList = new ArrayList();
			if (this.oleDbCommand_1 == null || this.oleDbCommand_1.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_1 = new OleDbCommand(string_1, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_1.CommandText = string_1;
			}
			OleDbDataReader oleDbDataReader = this.oleDbCommand_1.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				arrayList.Add(new Taobaoqiang
				{
					dataBatchId = oleDbDataReader["dataBatchId"].ToString(),
					dataStartTime = oleDbDataReader["dataStartTime"].ToString(),
					dataEndTime = oleDbDataReader["dataEndTime"].ToString(),
					num_iid = oleDbDataReader["itemId"].ToString(),
					title = oleDbDataReader["qiangTitle"].ToString(),
					ori_price = oleDbDataReader["originalPrice"].ToString(),
					price = oleDbDataReader["promoPrice"].ToString(),
					total_num = int.Parse(oleDbDataReader["totalNum"].ToString()),
					cmsplanrate = double.Parse(oleDbDataReader["cmsplanrate"].ToString()),
					brdgid = oleDbDataReader["brdgid"].ToString(),
					brdgcmsrate = double.Parse(oleDbDataReader["brdgcmsrate"].ToString()),
					picurl = oleDbDataReader["picurl"].ToString()
				});
			}
			oleDbDataReader.Close();
			string_2 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_18();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_11(out string string_1)
	{
		string string_2 = "delete from taobaoqiang";
		return this.method_17(string_2, out string_1);
	}
	public ArrayList method_13(double double_0, out string string_1)
	{
		string string_2 = string.Concat(new object[]
		{
			"select * from taobaoqing where cmsplanrate>=",
			double_0,
			" or brdgcmsrate>=",
			double_0
		});
		return this.method_15(string_2, out string_1);
	}
	public ArrayList method_14(out string string_1)
	{
		string string_2 = "select * from taobaoqing";
		return this.method_15(string_2, out string_1);
	}
	public ArrayList method_15(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			ArrayList arrayList = new ArrayList();
			if (this.oleDbCommand_1 == null || this.oleDbCommand_1.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_1 = new OleDbCommand(string_1, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_1.CommandText = string_1;
			}
			OleDbDataReader oleDbDataReader = this.oleDbCommand_1.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				arrayList.Add(new Taobaoqiang
				{
					num_iid = oleDbDataReader["itemId"].ToString(),
					title = oleDbDataReader["title"].ToString(),
					price = oleDbDataReader["actPrice"].ToString(),
					user_num_id = oleDbDataReader["sellerId"].ToString(),
					total_num = int.Parse(oleDbDataReader["totalNum"].ToString()),
					cmsplanrate = double.Parse(oleDbDataReader["cmsplanrate"].ToString()),
					brdgid = oleDbDataReader["brdgid"].ToString(),
					brdgcmsrate = double.Parse(oleDbDataReader["brdgcmsrate"].ToString()),
					picurl = oleDbDataReader["picurl"].ToString()
				});
			}
			oleDbDataReader.Close();
			string_2 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_18();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_16(out string string_1)
	{
		string string_2 = "delete from taobaoqing";
		return this.method_17(string_2, out string_1);
	}
	public bool method_17(string string_1, out string string_2)
	{
		bool result;
		try
		{
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			if (this.oleDbCommand_2 == null || this.oleDbCommand_2.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_2 = new OleDbCommand(string_1, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_2.CommandText = string_1;
			}
			this.oleDbCommand_2.ExecuteNonQuery();
			string_2 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_18();
			result = false;
		}
		return result;
	}
	public void method_18()
	{
		try
		{
			this.oleDbConnection_0.Close();
			this.oleDbConnection_0.Dispose();
			this.oleDbConnection_0 = null;
		}
		catch
		{
			this.oleDbConnection_0 = null;
		}
	}
	public void method_19()
	{
		string text = this.string_0 + "\\config\\淘清仓淘抢购.mdb";
		if (!File.Exists(text))
		{
			throw new Exception("目标数据库不存在,无法压缩");
		}
		try
		{
			this.oleDbConnection_0.Close();
			this.oleDbConnection_0.Dispose();
			this.oleDbConnection_0 = null;
			string text2 = "taoqingqiang" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";
			text2 = text.Substring(0, text.LastIndexOf("\\") + 1) + text2;
			string destconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text2 + ";Jet OLEDB:Database Password=taoqq<#>678";
			string sourceConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text + ";Jet OLEDB:Database Password=taoqq<#>678";
			new JetEngineClass().CompactDatabase(sourceConnection, destconnection);
			File.Copy(text2, text, true);
			File.Delete(text2);
		}
		catch
		{
		}
		finally
		{
			this.method_0();
		}
	}
	public ArrayList method_3(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			string text = "SELECT * FROM hicmsplan where itemId='" + string_1 + "'";
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			ArrayList arrayList = new ArrayList();
			if (this.oleDbCommand_1 == null || this.oleDbCommand_1.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_1 = new OleDbCommand(text, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_1.CommandText = text;
			}
			OleDbDataReader oleDbDataReader = this.oleDbCommand_1.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				arrayList.Add(new GClass15
				{
					string_1 = oleDbDataReader["upddatatime"].ToString(),
					string_2 = oleDbDataReader["foldername"].ToString()
				});
			}
			oleDbDataReader.Close();
			string_2 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_18();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_4(GClass15 gclass15_0, out string string_1)
	{
		bool result;
		try
		{
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			string text = "INSERT INTO tqqupd(datatype, upddatatime, foldername) VALUES ('{datatype}','{upddatatime}','{foldername}');";
			text = text.Replace("{datatype}", gclass15_0.string_0).Replace("{upddatatime}", gclass15_0.string_1).Replace("{foldername}", gclass15_0.string_2);
			if (this.oleDbCommand_0 == null || this.oleDbCommand_0.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_0 = new OleDbCommand(text, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_0.CommandText = text;
			}
			this.oleDbCommand_0.ExecuteNonQuery();
			string_1 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_1 = "出错啦！" + ex.ToString();
			this.method_18();
			result = false;
		}
		return result;
	}
	public ArrayList method_5(string string_1, out string string_2)
	{
		ArrayList result;
		try
		{
			string text = "SELECT * FROM tqqupd where datatype='{datatype}' order by upddatatime desc";
			text = text.Replace("{datatype}", string_1);
			if (this.oleDbConnection_0 == null)
			{
				this.method_0();
			}
			ArrayList arrayList = new ArrayList();
			if (this.oleDbCommand_1 == null || this.oleDbCommand_1.Connection.State != ConnectionState.Open)
			{
				this.oleDbCommand_1 = new OleDbCommand(text, this.oleDbConnection_0);
			}
			else
			{
				this.oleDbCommand_1.CommandText = text;
			}
			OleDbDataReader oleDbDataReader = this.oleDbCommand_1.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				arrayList.Add(new GClass15
				{
					string_0 = oleDbDataReader["datatype"].ToString(),
					string_1 = oleDbDataReader["upddatatime"].ToString(),
					string_2 = oleDbDataReader["foldername"].ToString()
				});
			}
			oleDbDataReader.Close();
			string_2 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_18();
			result = new ArrayList();
		}
		return result;
	}
	public bool method_6(string string_1, out string string_2)
	{
		string text = "delete from tqqupd where datatype='{datatype}'";
		text = text.Replace("{datatype}", string_1);
		return this.method_17(text, out string_2);
	}
	public ArrayList method_8(double double_0, out string string_1)
	{
		string string_2 = string.Concat(new object[]
		{
			"select * from taobaoqiang where cmsplanrate>=",
			double_0,
			" or brdgcmsrate>=",
			double_0
		});
		return this.method_10(string_2, out string_1);
	}
	public ArrayList method_9(out string string_1)
	{
		string string_2 = "select * from taobaoqiang";
		return this.method_10(string_2, out string_1);
	}
}
